package syn;

import java.util.concurrent.CopyOnWriteArrayList;

public class SafeThread
{
    public static void main(String[] args) throws InterruptedException
    {
        CopyOnWriteArrayList<String> list=new CopyOnWriteArrayList<String>();
        for (int i = 0; i < 1000; i++)
        {
            new Thread(()->{
                list.add(Thread.currentThread().getName());
            }).start();
        }
        Thread.sleep(300);
        System.out.println(list.size());
    }
}
